<template>
  <div class="el-dialog-div" ref="formBox">
    <span class="title">异常账户名:{{form.oppositeAccountName}}<span class="sub-title">账户:{{form.oppositeAccount}}</span> <span class="sub-title">金额:{{form.transactionAmount}}</span> </span>

    <el-form ref="form" :model="form" label-width="120px">

      <el-form-item label="入账操作" prop="mutualAccount">
        <el-radio v-model="radio" label="1">入金</el-radio>
        <el-radio v-model="radio" label="2">标记退款(说明:只是标记退款,实际还未进行转账操作)</el-radio>
      </el-form-item>

      <el-form-item v-if="radio==1" label="UID" prop="userId">
        <el-select v-model="queryParams.search" filterable placeholder="输入UID,名字,电话号码" :filter-method="query" style="width:100%" @change="selectUser">
          <el-option v-for="item in userList" :key="item.value" :label="item.label" :value="item">
          </el-option>
        </el-select>
      </el-form-item>

    </el-form>
  </div>
</template>

<script>
import { screenUser } from "@/api/system/user";

export default {
  name: 'FormView',
  props: {
    form: {
      type: Object,
    },
  },
  watch: {
    "queryParams": {
      deep: true,
      handler: function (newV, oldV) {
        this.getScreenUserList();
      },
    },
    radio(newV, oldV) {
      this.id = undefined;
      if (newV == 2) {
        this.params.userId = undefined;
      } else {
        this.getScreenUserList();
      }
    }
  },

  data() {
    return {
      search: '',
      radio: 0,
      params: {
        id: undefined,
        userId: undefined,
      },
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        search: undefined
      },
      userList: [],
      totalNum: 0
    }
  },

  mounted() {
    this.reset();
    // this.getScreenUserList();
    this.params.id = this.form.id;
  },

  methods: {
    reset() {
      this.params = {};
      this.queryParams.search = undefined;
      this.queryParams.pageNum = 1;
    },
    selectUser(data) {
      this.params.userId = data.id;
      this.queryParams.search = data.id;
    },
    query(params) {
      this.queryParams.search = params
      this.getScreenUserList();
    },
    getScreenUserList() {
      screenUser(this.queryParams).then((response) => {
        if (response.code == 200) {
          this.userList = response.data;
          this.userList.forEach(res => {
            res.label = res.id + '--' + res.phone + '--' + res.nickname;
            res.value = res.id;
          })
        }
      });
    },
  }
}
</script>

<style lang="scss" scoped>
.el-dialog-div {
  height: 70vh;
  overflow: auto;
  padding-right: 30px;
}
.table-box {
  margin-left: 40px;
}

.title {
  font-weight: bold;
  margin-left: 40px;
  line-height: 60px;
  color: #606266;
  .sub-title {
    margin-left: 40px;
  }
}
</style>
